package com.study.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * @author zhuzi
 * 2022/8/14 16:30
 */
@Slf4j
//@Service
public class CronComponent {
    @Async
    @Scheduled(cron = "0/1 * * * * ? ")
    public void deleteFile() throws InterruptedException {
        log.info("111delete success, time{}-{}:" ,Thread.currentThread(), LocalDateTime.now());
        TimeUnit.HOURS.sleep(1);
    }

    @Async
    @Scheduled(cron = "0/1 * * * * ? ")
    public void syncFile() {
        log.info("222sync success, time{}-{}:" ,Thread.currentThread(), LocalDateTime.now());
    }

}
